#ifndef _VEC_UTILS_H_
#define _VEC_UTILS_H_

#include "../d_Math/d_Math.h"

class VecUtils {

 public:

  static void Min(Vec3f &a, const Vec3f &b, const Vec3f &c ) {
    a[0] = (b[0] < c[0]) ? b[0] : c[0];
    a[1] = (b[1] < c[1]) ? b[1] : c[1];
    a[2] = (b[2] < c[2]) ? b[2] : c[2]; 
  }

  static void Max(Vec3f &a, const Vec3f &b, const Vec3f &c ) {
    a[0] = (b[0] > c[0]) ? b[0] : c[0];
    a[1] = (b[1] > c[1]) ? b[1] : c[1];
    a[2] = (b[2] > c[2]) ? b[2] : c[2]; 
  }

  static void Clamp(Vec3f &data, float low = 0, float high = 1) {
    if (data[0] < low) data[0] = low;  if (data[0] > high) data[0] = high;
    if (data[1] < low) data[1] = low;  if (data[1] > high) data[1] = high;
    if (data[2] < low) data[2] = low;  if (data[2] > high) data[2] = high; 
  }

  static void TransformDirection(const Mat4f &mat,
				 Vec3f &dir) {
    Vec4f dir4(dir,0);
    dir4 = xform(mat,dir4);
    dir = Vec3f(dir4[0],dir4[1],dir4[2]);
  }
};

#endif
